package cn.java68.zj.printer;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class Printer {

    @Value("惠普炫彩9660")
    private String paizi;
    @Value("1999")
    private int price;
    //预留纸张和墨水接口
    @Autowired
    //@Qualifier("colorInk")
    private Ink ink;

    @Autowired
    //@Qualifier("a4")
    //@Resource(name = "a4")
    private Paper paper;
    public Printer(){
        //保留
        System.out.println("无参数的构造方法");
    }

    public Printer(String paizi, int price, Ink ink, Paper paper) {
        System.out.println("4个参数的构造方法");
        this.paizi = paizi;
        this.price = price;
        this.ink = ink;
        this.paper = paper;
    }

    public void print(String s){
        try {
            Thread.sleep(1800);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("打印机品牌是:"+paizi+",价格是:"+price+"元");
        System.out.println("使用颜色:"+ink.getColor()+"打印");
        paper.print(s);//打印
    }

//    public void setBrand(String brand) {
//        this.paizi = brand;
//    }
//
//    public void setPrice(int price) {
//        this.price = price;
//    }
//
//    public void setInk(Ink ink) {
//        this.ink = ink;
//    }
//
//    public void setPaper(Paper paper) {
//        this.paper = paper;
//    }
}
